<?php
class CommonAction extends Action {
	function _initialize(){
		if(!$_SESSION["isLoginH"]) {
			$this->logout();
			$this->display("admin/user/login.tpl");
		}else{
			$umodel=new UserModel();

			$user=$umodel->find($_SESSION["uid"]);

			if($user["disable"]){
				$this->logout();
				$this->assign("message", "该用户被禁用.");
				$this->assign("className", "login-msg");
				$this->display("admin/user/login.tpl");
			}elseif(!$user["allow_dlht"]){
				$this->assign("message", "你没有登录后台的权限");
				$this->assign("className", "login-msg");
				$this->display("admin/user/login.tpl");
			}
		}
	} 	

	function logout() {
		$_SESSION = array();
		if (isset($_COOKIE[session_name()])) {
   			setcookie(session_name(), '', time()-42000, '/');
		}
		session_destroy();
		if($_GET["redirect"]){
			$this->redirect("admin.php", "index", "index");
		}
	}
}

